package com.itheima.kafka.boot;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class MapController {

    @Autowired
    KafkaTemplate kafkaTemplate;

    @GetMapping("map")
    public String helloMap(){
        Map map=new HashMap();
        map.put("姓名","小明");
        map.put("年龄","12");
        map.put("性别","男");
        kafkaTemplate.send("map-topic", JSON.toJSONString(map));
        return "ok";
    }
}
